package sk.fiit.icp.event.view;

import java.util.Date;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.request.mapper.parameter.PageParameters;

import sk.fiit.icp.components.Utils;

public class EventPage extends WebPage {

	public EventPage(PageParameters params) {
		int eventId = 0;
		int window = 0;
		String startT = Utils.dateToJSString( new Date() );
		String endT = Utils.dateToJSString( new Date() );
		setOutputMarkupId( true );
		if ( !params.isEmpty() && params.get( "eventId" ).toString() != null
				&& Integer.valueOf( params.get( "eventId" ).toString() ).intValue() > 0 ) {
			eventId = Integer.valueOf( params.get( "eventId" ).toString() ).intValue();
		}

		if ( !params.isEmpty() && params.get( "iswindow" ).toString() != null ) {
			window = Integer.valueOf( params.get( "iswindow" ).toString() ).intValue();
		}

		if ( !params.isEmpty() && params.get( "startTime" ).toString() != null ) {
			startT = params.get( "startTime" ).toString();
		}

		if ( !params.isEmpty() && params.get( "endTime" ).toString() != null ) {
			endT = params.get( "endTime" ).toString();
		}

		add( new EventPanel( "bodyPanel", eventId, window, startT, endT ) );
	}

}
